package com.learning.platform.repository;

import com.learning.platform.entity.Post;
import com.learning.platform.enums.PostStatus;
import com.learning.platform.enums.PostType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface PostRepository extends JpaRepository<Post, Long> {
    
    Page<Post> findByCourseIdAndStatus(Long courseId, PostStatus status, Pageable pageable);
    
    Page<Post> findByCourseIdAndPostTypeAndStatus(Long courseId, PostType postType, PostStatus status, Pageable pageable);
    
    Page<Post> findByUserIdAndStatus(Long userId, PostStatus status, Pageable pageable);
    
    long countByCourseId(Long courseId);
    
    long countByCourseIdAndPostType(Long courseId, PostType postType);
}

